﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mimoza.Common;
using Mimoza.Transport;

namespace Mimoza.DBLayer.Transport
{
    public class HostsRepositoryCustomRequest
    {
        public enum CustomOperationType
        {
            None,
            GetHost,
            GetHostByMac
        }

        public HostsRepositoryCustomRequest()
        {
        }

        public HostsRepositoryCustomRequest(CustomOperationType operationType)
        {
            Init(operationType, null);
        }

        public HostsRepositoryCustomRequest(CustomOperationType operationType,
            string argument1)
        {
            Init(operationType, argument1);
        }

        void Init(CustomOperationType operationType, string argument1)
        {
            OperationType = operationType;
            Argument1 = argument1;
        }

        public CustomOperationType OperationType = CustomOperationType.None;
        public string Argument1 = null;
    }

    public class HostsRepositoryTranferRequest :
        TransferObjectGeneric<HostsRepositoryTranferRequest, RepositoryReply<HostRecord>>
    {
        public HostsRepositoryTranferRequest()
        {
        }

        public HostsRepositoryTranferRequest(Operation oper, HostRecord record)
        {
            Request.Operation = oper;
            Request.Object = record;
        }

        public HostsRepositoryTranferRequest(HostsRepositoryCustomRequest customReq)
        {
            Request.Operation = Operation.Custom;
            Request.CustomRequest = customReq;
        }

        override public RepositoryReply<HostRecord> ProcessRequest()
        {
            return Request.Process(Connection, Repository) as RepositoryReply<HostRecord>;
        }

        public RepositoryRequest<
            HostRecord,
            ServerRepository<HostRecord, HostsRepositoryCustomRequest, IDBHostRepository>,
            HostsRepositoryCustomRequest,
            IDBHostRepository> Request = new RepositoryRequest<
                HostRecord,
                ServerRepository<HostRecord, HostsRepositoryCustomRequest, IDBHostRepository>,
                HostsRepositoryCustomRequest,
                IDBHostRepository>();

        public static ServerRepository<HostRecord, HostsRepositoryCustomRequest, IDBHostRepository> Repository = null;
    }
}
